# Maintainer: Anatol Pomozov
# Maintainer: Filipe Lains (FFY00) <lains@archlinux.org>
# Contributor: Thomas Krug <t.krug@elektronenpumpe.de>

pkgname=libsigrokdecode
pkgver=0.5.3
pkgrel=6
pkgdesc='C library that provides protocol decoding for logic analyzers, protocol decoders, etc.'
arch=('loong64' 'x86_64')
url='https://www.sigrok.org/wiki/Libsigrokdecode'
license=('GPL3')
depends=('glib2' 'python')
source=("https://sigrok.org/download/source/libsigrokdecode/libsigrokdecode-$pkgver.tar.gz"
        $pkgname-py39.patch::https://github.com/sigrokproject/libsigrokdecode/commit/9b0ad5177bd6.patch
        use-python3-embed.pc-as-a-fallback.patch)
sha512sums=('23393504b68135ed4ae8e8a654df024620af02e84fa3955956c61899388812229108155b4ae8d946e61f33dc8a8807db090d608350548a7a717d966442b07b9e'
            'f1b26c227fc0eb5e831563e328a20beeb2412576bc50a0a241923dad1ebd1bd0eb07f2b3a4230ba99e3bf8db04cac6480ed8724e9727514d65cb3afe6838e189'
            'a4b22157898308cd248decf977e637e214c8f75aca2b8af4803a01208d0cbbe11ddb232e3d356e531e72c43a1a0ff07bc08e30f8378fa67f23f23665a7e53cb1')

prepare() {
  cd $pkgname-$pkgver
  patch -Np1 -i ../$pkgname-py39.patch
  # https://sourceforge.net/p/sigrok/mailman/message/37168276/
  patch -Np1 -i ../use-python3-embed.pc-as-a-fallback.patch
}

build() {
  cd $pkgname-$pkgver

  autoreconf --force --install . # it is a content of upstream's ./autogen.sh
  ./configure --prefix=/usr

  make
}

package() {
  cd $pkgname-$pkgver

  make DESTDIR="$pkgdir" install
}
